﻿using System;
using System.Collections;

namespace csharpcore7_ch3_Interface
{
    class Chapt3_6Interface
    {      
        static void _Main() {
            IEnumerator e = new CountDown();
            while (e.MoveNext()) {
                Console.Write(e.Current); //109876543210
            }
            Console.WriteLine();
        }
    }
    /// <summary>
    /// System.Collections.IEnumerator:支持对非泛型集合的简单迭代。
    /// 接口成员总是隐式public的，并且不能和访问权限修饰符声明。
    /// </summary>
    internal class CountDown : IEnumerator
    {
        int count = 11;
        public bool MoveNext() => count-- > 0;
        public object Current => count;
        public void Reset() { 
            throw new NotSupportedException();
        }
    }
}
